feat(gateway): 图/视频调用经进程内 Gateway 做重试、Fallback 与观测 - #331
Conversation
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
并发过期不再 KeyError;跳过开路型号会记 fallback_used;视频分阶段耗时写入 trace;提交未拿到 job_id 时除 429 外不再换型号。 Co-authored-by: Cursor <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Review conclusion
整体分层与提交后不重复建单的主路径一致,但视频错误状态仍有两处会扩大重试或污染后续路由:轮询 52x 被 adapter 与 Gateway 双重重试,以及本次请求明确禁止 fallback 时仍提前打开型号熔断。建议修正这两个状态转换后再合入。
验证:完整检查了固定 diff 4103106...19fce6a 的 gateway、Sufy adapter、executor/API 接入与相关测试;git diff --check 通过。当前运行环境缺少 uv 和项目 Python 依赖,未能执行 pytest。
|
我的 #324 也改 sufy.py——抽了个 ChatCompletionsFace 让出图和判官共用建连和重试,和你这版重叠。你把重试整个移到 Gateway 之后那层就多余了,所以不管哪边先合,我都按你的 AdapterResult 收,不另起一套。 |
现按照我的来做吧。咱们把重试的逻辑统一放在gateway做,这样方便后续的链路追踪、熔断、限流等逻辑的引入,以及更换模型路由。这样看起来,重试逻辑也不会太过散乱,你觉得呢? |
5b57caf to
b782d7d
Compare
429 换 key 不换模型,522 跳过该入口剩余 key;Chat 走同一套路由。 AttemptTrace 只保留热字段,排障详情进 AttemptDetail。
xyh202131
left a comment
There was a problem hiding this comment.
批准:重试、Fallback、熔断与 trace 集中到 Gateway,且视频拿到 job_id 后不重复下单,避免重复扣费;请求链可追踪,错误分类覆盖完整。
路线选择前误用未赋值的 master,且不应再把型号传给 _get_generator。
xyh202131
left a comment
There was a problem hiding this comment.
批准:重试、Fallback、熔断与 trace 集中到 Gateway,视频拿到 job_id 后不重复下单;最新修正也去除了重复 generate 调用,避免重复请求与扣费。
Chat 工厂校验 AI_API_KEY / AI_CHAT_MODEL;图片失败解冻积分;stance 测试改打 generate_character_action。
|
Deployment failed for project windup with the following error: Learn More: https://vercel.com/huyan-s-projects1?upgradeToPro=build-rate-limit |
Summary
sufy.py抽到windup_framework.gateway。业务仍只调ImageProvider.gen_image/VideoProvider.i2v。job_id后不再 POST 第二单,仅failed/cancelled允许换型号新开。request_id,便于从日志捞 attempt 链。积分扣费仍走现有QUOTA_*。Fixes #330
Test plan
backend/下 gateway + sufy + custom_action + executor 等相关测试 167 passedjob_id后,轮询 429/失败不再开第二单;上游failed/cancelled才换型号video_model仍 4xxrequest_id=